<!---eDTR main--->
<!---by mico--->


<cfset existPID = 0>



<cfif structKeyExists(Form, "btnViewAll")>
	<cfset pid = client.chapa>
<cfelse>
	<cfif structkeyexists(url,"pid")>
  	<CFSET PID = URLDecode(Decrypt(url.pid,client.ek))> 
		<cfset existPID = 1>
    </cfif>	
</cfif>

<CFSET sEDTRCODE = URLDecode(Decrypt(url.id,client.ek))>

<cfset thedocnumber = "">
<CFSET EDTRROUTED = false>
	<CFQUERY NAME="getRECORD" DATASOURCE="#client.company_dsn#">
		SELECT A.TKFILENAME_FK, A.EDTRGROUP, A.SHAREDVIEW, A.SHAREDUPDATE, A.GROUPCODE,
			B.CUTOFFSTARTDATE, B.CUTOFFENDDATE, A.CUTOFF
		FROM ECRGDTR A, CRGTKFILES B
		WHERE A.EDTRCODE = '#sEDTRCODE#' 
			AND A.TKFILENAME_FK = B.TKFILENAME
	</CFQUERY>
	
	<cfset cfCutOffEnd = getRECORD.CUTOFF>
	
			<CFQUERY NAME = "qryGRGTRANSACTION" datasource="#CLIENT.GLOBAL_DSN#">
		SELECT B.IBOSEDSN, B.DATABASENAME
		FROM GRGTRANSACTION A, GRGDATALOCATION B
		WHERE A.DATALOCATIONCODE = B.DATALOCATIONCODE
			AND A.COMPANYCODE = <cfqueryparam value="#CLIENT.COMPANYCODE#" cfsqltype="cf_sql_varchar">
	</CFQUERY>
	<CFIF getRECORD.RECORDCOUNT>
		<CFSET sTHETK = getRECORD.TKFILENAME_FK>
		<CFSET dCUTOFFSTART = GETRECORD.CUTOFFSTARTDATE>
		<CFSET dCUTOFFEND = GETRECORD.CUTOFFENDDATE>
	<CFELSE>
		<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH="100%">
		<CFOUTPUT>
		<TR>
			<TD ALIGN="right"><IMG SRC="#client.image_path##session.site_ibose#"></TD>
			<TD NOWRAP CLASS="bold14" WIDTH="100%"><FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><BR>iBOS/e eDTR</TD>
		</TR>
		<TR height="100"> &nbsp; </TR>
		<TR> <TD colspan="100" align="center">The attendance file was not found. Please contact your administrator. </TD>	</TR>
		<TR> <TD><BUTTON onClick="javascript: self.close();"> CLOSE </BUTTON></TD> </TR>
		</CFOUTPUT>
		</TABLE>
		<CFABORT>
	</CFIF>
<cfparam name="session.themessage" default="">
<cfif not structKeyExists(Form, "btnViewAll") and not existPID>
	<CFQUERY name="qryECINDTRUPDATE" datasource="#CLIENT.COMPANY_DSN#">
		SELECT DOCNUMBER,APPROVED,ROUTEID
		FROM ECINDTRUPDATE
		WHERE EDTRCODE_FK = <cfqueryparam value="#sEDTRCODE#" cfsqltype="cf_sql_varchar">
			AND PERSONNELIDNO = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
			<!---AND ROUTEID IS NULL
			AND (APPROVED NOT IN ('Y','N','C') OR APPROVED IS NULL)--->
	</CFQUERY>
	<CFIF qryECINDTRUPDATE.RECORDCOUNT >
		<cfquery name="qrypending" dbtype="query">
			select docnumber
			from qryecindtrupdate
			where approved = 'S'
		</cfquery>
		<cfif qrypending.recordcount>
			<cfset edtrrouted = true>
		<cfelse>
			<cfquery name="qrytoberouted" dbtype="query">
				select docnumber
				from qryecindtrupdate
				where approved = 'R' or routeid is null
			</cfquery>
			<cfif qrytoberouted.recordcount>
				<CFSET THEDOCNUMBER = qrytoberouted.DOCNUMBER>
			</cfif>
		<!---<CFIF qryECINDTRUPDATE.APPROVED EQ "">
			<CFSET EDTRROUTED = FALSE>
		<CFELSE>
			<CFSET EDTRROUTED = TRUE>
		</CFIF>--->
		</cfif>
	<!---<cfelse>
		<CFSET EDTRROUTED = false>--->
	</CFIF>
<cfelseif existPID>
	<CFQUERY name="qryECINDTRUPDATE" datasource="#CLIENT.COMPANY_DSN#">
		SELECT DOCNUMBER,APPROVED,ROUTEID
		FROM ECINDTRUPDATE
		WHERE EDTRCODE_FK = <cfqueryparam value="#sEDTRCODE#" cfsqltype="cf_sql_varchar">
			AND PERSONNELIDNO = <cfqueryparam value="#PID#" cfsqltype="cf_sql_varchar">
			<!---AND ROUTEID IS NULL
			AND (APPROVED NOT IN ('Y','N','C') OR APPROVED IS NULL)--->
	</CFQUERY>
	<CFIF qryECINDTRUPDATE.RECORDCOUNT >
		<cfquery name="qrypending" dbtype="query">
			select docnumber
			from qryecindtrupdate
			where approved = 'S'
		</cfquery>
		<cfif qrypending.recordcount>
			<cfset edtrrouted = true>
		<cfelse>
			<cfquery name="qrytoberouted" dbtype="query">
				select docnumber
				from qryecindtrupdate
				where approved = 'R' or routeid is null
			</cfquery>
			<cfif qrytoberouted.recordcount>
				<CFSET THEDOCNUMBER = qrytoberouted.DOCNUMBER>
			</cfif>
		<!---<CFIF qryECINDTRUPDATE.APPROVED EQ "">
			<CFSET EDTRROUTED = FALSE>
		<CFELSE>
			<CFSET EDTRROUTED = TRUE>
		</CFIF>--->
		</cfif>
	<!---<cfelse>
		<CFSET EDTRROUTED = false>--->
	</CFIF>
</cfif>

<!---
<cfif structkeyexists(form,"btnlink")>
	<cfset sedtrmess = "">
	<cfif thedocnumber eq "" and not edtrrouted>
		<CFSET EDTRROUTED = FALSE>
		<CFMODULE TEMPLATE="#client.common_path#cfm_autogen_bose.cfm" TABLENAME = "ECINDTRUPDATE"
			COLUMNNAME = "DOCNUMBER" DATASOURCE="#client.company_dsn#">
		<CFSET THEDOCNUMBER = AUTOGENVALUE>
		<CFQUERY name="insertECINDTRUPDATE" datasource="#CLIENT.COMPANY_DSN#">
			INSERT INTO ECINDTRUPDATE(DOCNUMBER,GUID,PERSONNELIDNO,EDTRCODE_FK,RECCREATEDBY,RECDATECREATED)
			VALUES('#THEDOCNUMBER#','#CLIENT.GUID#','#CLIENT.CHAPA#','#sEDTRCODE#','#CLIENT.USERID#',#NOW()#)
		</CFQUERY>
		<cfset session.themessage = "Application was included in the eDTR succesfully." &sedtrmess>
	</CFIF>
	<cfif not edtrrouted>
		<cfquery name="getpreprocess" datasource="#client.company_dsn#">
			select preprocess,tablename_fk
			from ecrgforms
			where formcode = <cfqueryparam value="#form.linkformcode#" cfsqltype="cf_sql_varchar">
		</cfquery>
		<cfset thepreprocess = getpreprocess.preprocess>
		<cfif thepreprocess eq "">
			<cfquery name="linkecindtrupdatedtl" datasource="#client.company_dsn#">
				insert into ecindtrupdatedtl(docnumber,formcode_fk,docnumber_fk,pid,reccreatedby,recdatecreated)
				values('#thedocnumber#','#form.linkformcode#','#form.linkdocnumber#','#form.linkpid#','#client.userid#',#now()#)		
			</cfquery>
			<cfset pid = form.linkpid>
			<cfset session.themessage = "Application was included in the eDTR succesfully." &sedtrmess>
		<cfelse>
			<cfset thetable = getpreprocess.tablename_fk>
			<!---validate preprocess--->
			<cfquery name="getentry" datasource="#client.company_dsn#">
				select * from #getpreprocess.tablename_fk#
				where docnumber = '#form.linkdocnumber#' and personnelidno = '#form.linkpid#'
			</cfquery>
			<cfset lpreprocessvalidated = "No">
			<cfset lPreProcessShowMsg = "Yes">
			<cfset url.docnumber = getentry.docnumber>
			<cfsilent>
			<cfinclude template="../../eforms/pre_activities/#thepreprocess#">
			</cfsilent>
			<cfif lpreprocessvalidated>
				<cfquery name="linkecindtrupdatedtl" datasource="#client.company_dsn#">
				insert into ecindtrupdatedtl(docnumber,formcode_fk,docnumber_fk,pid,reccreatedby,recdatecreated)
				values('#thedocnumber#','#form.linkformcode#','#form.linkdocnumber#','#form.linkpid#','#client.userid#',#now()#)		
				</cfquery>
				<cfset pid = form.linkpid>
				<cfset session.themessage = "Application was included in the eDTR succesfully.">
			<cfelse>
				<cfset session.themessage = "Application is invalid.<br>" &sedtrmess>
			</cfif>
		</cfif>
	</cfif>
	<cfset pid = form.linkpid>
<cfelseif structkeyexists(form,"btnremovelink")>
	<cfquery name="delfromlinked" datasource="#client.company_dsn#">
		delete from ecindtrupdatedtl
		where docnumber = '#thedocnumber#'
			and formcode_fk = '#form.linkformcode#'
			and docnumber_fk = '#form.linkdocnumber#'
	</cfquery>
	<cfset pid = form.linkpid>
	<cfset session.themessage = "Application was removed from the eDTR succesfully.">
<cfelseif structkeyexists(form,"btngo")>
	<cfset pid = form.formpid>
	<cfset url.newapp = 1>
	<cfinclude template="./update.cfm">
<cfelseif STRUCTKEYEXISTS(FORM,"btnSAVENEWAPP")>
	<cfset PID = form.formPID>
	<cfset thetable = form.formtable>
	<cfset theformcode = form.formformcode>
	<CFINCLUDE template="func_savenewapp.cfm">
<cfelseif STRUCTKEYEXISTS(FORM,"btnnewapppx")>
	<cfset PID = form.formPID>
	<cfinclude template="func_savenewapppx.cfm">
<cfelseif structkeyexists(form,"btnpid")>
	<cfset PID = form.btnpid>
<cfelseif structkeyexists (form,"btnRoute")>
--->
<cfif structkeyexists(form,"btnpid")>
	<cfset PID = form.btnpid>
<cfelseif structKeyExists(Form, "btnRoute")>
	<cfset pid = Form.personId>
	
	<cfquery name="getGuid" datasource="#client.company_dsn#">
		SELECT GUID FROM CMFPA
		WHERE PERSONNELIDNO = '#pid#'
	</cfquery>
	
	<cfif thedocnumber eq "">
		<CFSET EDTRROUTED = FALSE>
		<CFMODULE TEMPLATE="#client.common_path#cfm_autogen_bose.cfm" TABLENAME = "ECINDTRUPDATE"
			COLUMNNAME = "DOCNUMBER" DATASOURCE="#client.company_dsn#">
		<CFSET THEDOCNUMBER = AUTOGENVALUE>
		
		<cfset rem = "">
		
		<cfif Form.swForm eq 1>
			<cfset rem = "Within the Cut-off">
		<cfelse>
			<cfset rem = "Beyond the Cut-off">
		</cfif>
		
		<CFQUERY name="insertECINDTRUPDATE" datasource="#CLIENT.COMPANY_DSN#">
			INSERT INTO ECINDTRUPDATE
				(
					DOCNUMBER
					,GUID
					,PERSONNELIDNO
					,DESCRIPTION
					,REMARKS
					,EDTRCODE_FK
					,RECCREATEDBY
					,RECDATECREATED
				)
			VALUES
				(
					'#THEDOCNUMBER#'
					
					<!--- ,'#CLIENT.GUID#'
					,'#CLIENT.CHAPA#' --->
					
					,'#getGuid.GUID#'
					,'#pid#'
					,'Cutoff Date: #DateFormat(getRECORD.CUTOFFSTARTDATE, "mmm-dd-yyyy")# to #DateFormat(getRECORD.CUTOFFENDDATE, "mmm-dd-yyyy")#'
					,'#rem#'
					,'#sEDTRCODE#'
					,'#CLIENT.USERID#'
					,#NOW()#)
		</CFQUERY>
	</cfif>
	<!---
	<CFQUERY NAME="getROUTINGFORM" DATASOURCE="#CLIENT.COMPANY_DSN#">
		SELECT FORMCODE, TEMPLATECODE_FK 
		FROM ECRGFORMS <!---WITH (NOLOCK)--->
		WHERE TABLENAME_FK = 'ECINDTRUPDATE'
	</CFQUERY>
		SELECT FORMCODE, TEMPLATECODE_FK 
		FROM ECRGFORMS
		WHERE TEMPLATECODE_FK = 'EFORM_DTR_ROUTE'
	--->
	
	<CFQUERY NAME="getROUTINGFORM" DATASOURCE="#CLIENT.COMPANY_DSN#">
		SELECT FORMCODE, TEMPLATECODE_FK 
		FROM ECRGFORMS
		WHERE TEMPLATECODE_FK = 'EFORM_DTR_ROUTE'
	</CFQUERY>
	
	<CFQUERY NAME="getROUTINGFORMTEMPLATE" DATASOURCE="#CLIENT.GLOBAL_DSN#">
		SELECT TEMPLATEPATH 
		FROM EGRGTEMPLATES <!---WITH (NOLOCK)--->
		WHERE TEMPLATECODE = '#getROUTINGFORM.TEMPLATECODE_FK#'
	</CFQUERY>
	<CFIF getROUTINGFORM.RECORDCOUNT and not edtrrouted>
		<CFPARAM NAME = "sMESS" default="">
		<cfset session.tablocation = "../../edtr/">
		<CFSET sAnchor = "?id=" & "#URLENCODEDFORMAT(encrypt("#getROUTINGFORM.FORMCODE#", client.ek))#" & "&DOCNUMBER=#THEDOCNUMBER#&edit=1&smess=#smess#" & 
							"&PERSONNELIDNO=#pid#">
		<!--- added PERSONNELIDNO var on url --->
		<CFLOCATION url="#CLIENT.DOMAIN##getROUTINGFORMTEMPLATE.TEMPLATEPATH##sAnchor#"  ADDTOKEN="No">
	<cfelse>
		<cfset session.themessage = "You have an eDTR updating form that is currently on-process. <br /> It has to be acted upon first before you can route another one for this attendance cut-off.">
	</CFIF>
</cfif>
<cfif edtrrouted>
	<cfset session.themessage = session.themessage &"<br />You have an eDTR updating form that is currently on-process. <br /> It has to be acted upon first before you can route another one for this attendance cut-off.">
</cfif>

<!---<CFIF ISDEFINED("FORM.btnBackHome")>
	<CFLOCATION url="#client.domain#edtr/">
</CFIF>
<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm">
<CFSET sDateNow = dateResult>
<CFSET webCompCode = "dtr">
<CFSET session.tabId = "dtr">--->

<CFSET sEDTRCODEUrlEnc = URLEncodedFormat(Encrypt(sEDTRCODE,client.ek))>

<CFPARAM NAME="sWarn" default="">
<CFPARAM NAME="sMess" DEFAULT="">
<cfquery name = "getgroupcode" datasource="#client.company_dsn#">
	select groupcode
	from ecrgdtr
	where edtrcode = <cfqueryparam value="#sedtrcode#" cfsqltype="cf_sql_varchar">
</cfquery>

<!---<cfquery name="qryecrgdtrdtl" datasource="#client.company_dsn#">
	select a.formcode_fk,a.datefield,b.tablename_fk
	from ecrgdtrdtl a, ecrgforms b
	where a.edtrcode = '#sedtrcode#'
		and a.formcode_fk = b.formcode
</cfquery>--->
<cfquery name="qryecrgdtrdtl" datasource="#client.company_dsn#">
	select formcode_fk,datefield
	from ecrgdtrdtl
	where edtrcode = <cfqueryparam value="#sedtrcode#" cfsqltype="cf_sql_varchar">
</cfquery>
<cfquery name="qryECRGFORMS" datasource="#client.company_dsn#">
	select formcode,tablename_fk,description, TEMPLATECODE_FK
	from ecrgforms
	where formcode in (<cfqueryparam value="#valuelist(qryecrgdtrdtl.formcode_fk)#" list="yes" cfsqltype="cf_sql_varchar">)
</cfquery>
<cfset groupcode = getgroupcode.groupcode>
<cfset masterviewgroup = "">
<cfset masterupdategroup = "">
<cfset masterupdate = "">
<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTDTR"
		USERFIELD = "USERGRPID_FK" RECORDFIELD = "EDTRCODE_FK" RECORDID = "master" BOOLEANFIELDS="ISUPDATE,ISVIEWGROUP,ISUPDATEGROUP">
<cfset masterviewgroup = fieldisviewgroup>
<cfset masterupdategroup = fieldisupdategroup>
<cfset masterupdate = fieldisupdate>
<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTDTR"
		USERFIELD = "USERGRPID_FK" RECORDFIELD = "EDTRCODE_FK" RECORDID = "#sEDTRCODE#" BOOLEANFIELDS="ISUPDATE,ISVIEWGROUP,ISUPDATEGROUP">
<cfif (fieldisviewgroup eq "Y" or masterviewgroup eq "Y") and structkeyexists(form,"btnViewAll")>
	<CFQUERY NAME = "qryCMFPA" datasource="#CLIENT.COMPANY_DSN#">
		SELECT #GROUPCODE#
		FROM CMFPA
		WHERE PERSONNELIDNO = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
	</CFQUERY>
	<cfset groupcodeval = evaluate("qryCMFPA.#groupcode#")>
	<cfquery name="getgroupmates" datasource="#client.company_dsn#">
		select personnelidno,lastname
		from cmfpa
		where #groupcode# = <cfqueryparam value="#groupcodeval#" cfsqltype="cf_sql_varchar">
		AND EMPLOYMENTSTATUS IN (SELECT EMPLOYMENTSTATUS FROM CLKEMPLOYMNTSTATUS WHERE ISACTIVE = 'Y')
			order by lastname
	</cfquery>
<cfelseif structkeyexists(url,"pid") or structkeyexists(form,"hiddownloadpid") or structkeyexists(variables,"pid")>
	<cfif structkeyexists(form,"hiddownloadpid")>
		<cfset pid = form.hiddownloadpid>
	</cfif>
	<CFQUERY NAME = "qryCMFPA" datasource="#CLIENT.COMPANY_DSN#">
		SELECT #GROUPCODE#
		FROM CMFPA
		WHERE PERSONNELIDNO = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
	</CFQUERY>
	<cfset groupcodeval = evaluate("qryCMFPA.#groupcode#")>
	<cfquery name="getgroupmates" datasource="#client.company_dsn#">
		select personnelidno
		from cmfpa
		where personnelidno = <cfqueryparam value="#pid#" cfsqltype="cf_sql_varchar">
	</cfquery>
<cfelse>
	<CFQUERY NAME = "qryCMFPA" datasource="#CLIENT.COMPANY_DSN#">
		SELECT #GROUPCODE#
		FROM CMFPA
		WHERE PERSONNELIDNO = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
	</CFQUERY>
	<cfset groupcodeval = evaluate("qryCMFPA.#groupcode#")>
	<cfquery name="getgroupmates" datasource="#client.company_dsn#">
		select personnelidno
		from cmfpa
		where personnelidno = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
	</cfquery>
</cfif>
<!---<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTDTR"
		USERFIELD = "USERGRPID_FK" RECORDFIELD = "EDTRCODE_FK" RECORDID = "#sEDTRCODE#" BOOLEANFIELDS="ISUPDATE,ISUPDATEGROUP,ISVIEWGROUP">--->
	<CFSET STDB = "">
	<CFLOOP QUERY = "qryGRGTRANSACTION">
		<!---CFTRY--->
		<CFQUERY NAME = "qryFINDTRANDB" datasource="#IBOSEDSN#">
		<!---SELECT NAME FROM SYSOBJECTS
		WHERE NAME = <cfqueryparam value="#sTHETK#D" cfsqltype="cf_sql_varchar">--->
        	SELECT COUNT(PERSONNELIDNO) FROM #sTHETK#D
         
		</CFQUERY>
		<CFIF qryFINDTRANDB.RECORDCOUNT>
			<CFSET sTDB = IBOSEDSN>
			<CFSET sTHEDBNAME = DATABASENAME>
			<CFBREAK>
		</CFIF>
		<!---CFCATCH>
		</CFCATCH>
		</CFTRY--->
	</CFLOOP>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
	<HTML>
	<HEAD>
		<TITLE>iBOS/e eDTR</TITLE>
		<CFOUTPUT>
		<LINK REL="StyleSheet" HREF="#client.wstheme_path##client.empcolor#.css" TYPE="text/css">
		</CFOUTPUT>
		
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Lock Table Headings 5</title>
<style type='text/css'>

/* Scrollable Content Height */
.scrollContent {height:80px;overflow-x:hidden;overflow-y:auto;}
.scrollContent tr {
 height: auto;
 white-space: nowrap;
}

/* Prevent Mozilla scrollbar from hiding right-most cell content */
.scrollContent tr td:last-child {
 padding-right: 20px;
}

/* Fixed Header Height */
.fixedHeader tr {
 position: relative;
 height: auto;
}

/* Put border around entire table */
div.TableContainer {
 border: 3px solid #7DA87D;
}

/* Table Header formatting */
.headerFormat {
 background-color: BLACK;
 color: #FFFFFF;
 margin: 3px;
 padding: 2px;
 white-space: nowrap;
 font-family: Helvetica;
 font-size: 16px;
 text-decoration: none;
 font-weight: bold;
}
.headerFormat tr td {
 border: 2px solid #000000;
 background-color: BLACK;
}

/* Table Body (Scrollable Content) formatting */
.bodyFormat tr td {
	background-color: #000000;
	color: #000000;
	
	margin: 3px;
	padding: 1px;
	border: 1px solid #000000 ;
	font-family: Helvetica;
	font-size: 12px;
}

/* Use to set different color for alternating rows */
.alternateRow {
  background-color: BLACK;
}



</style>
<!--[if IE]>
<style type="text/css">
/* IE Specific Style addition to constrain table from automatically growing in height */
div.TableContainer {
 height: 121px; 
 overflow-x:hidden;
 overflow-y:auto;
}
</style>
<![endif]-->
	</HEAD>
	<CFSET isCommand="">
	<BODY LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>
	
<cfloop query="getgroupmates" >
	<cfset pid = personnelidno>
	
	
	<!--- added by Alven M. Alinan 07-06-2011 --->
	<!--- validation for viewing all, to filter only the routed eDTRs --->
	<CFQUERY name="qryECINDTRUPDATE" datasource="#CLIENT.COMPANY_DSN#">
			SELECT DOCNUMBER,APPROVED,ROUTEID
			FROM ECINDTRUPDATE
			WHERE EDTRCODE_FK = <cfqueryparam value="#sEDTRCODE#" cfsqltype="cf_sql_varchar">
				AND PERSONNELIDNO = <cfqueryparam value="#pid#" cfsqltype="cf_sql_varchar">
				<!---AND ROUTEID IS NULL
				AND (APPROVED NOT IN ('Y','N','C') OR APPROVED IS NULL)--->
		</CFQUERY>
		<CFIF qryECINDTRUPDATE.RECORDCOUNT >
			<cfquery name="qrypending" dbtype="query">
				select docnumber
				from qryecindtrupdate
				where approved = 'S'
			</cfquery>
			<cfif qrypending.recordcount>
				<cfset edtrrouted = true>
			<cfelse>
				<cfquery name="qrytoberouted" dbtype="query">
					select docnumber
					from qryecindtrupdate
					where approved = 'R' or routeid is null
				</cfquery>
				<cfif qrytoberouted.recordcount>
					<CFSET THEDOCNUMBER = qrytoberouted.DOCNUMBER>
				</cfif>
			<!---<CFIF qryECINDTRUPDATE.APPROVED EQ "">
				<CFSET EDTRROUTED = FALSE>
			<CFELSE>
				<CFSET EDTRROUTED = TRUE>
			</CFIF>--->
			</cfif>
		<!---<cfelse>
			<CFSET EDTRROUTED = false>--->
		</CFIF>
	<!--- validation for viewing all, to filter only the routed eDTRs (End) --->
	
	<!---<cftrace category="mico" var="stdb">--->
	<CFIF STDB NEQ "">
		<CFQUERY NAME = "qryDETAILEDATTD" datasource="#sTDB#">
			SELECT PERSONNELIDNO, REFERENCEDATE, ITEMCODE, ITEMVALUE, DAYTYPE, SKEDIN, SKEDOUT,
				ACTUALIN, ACTUALOUT, WORKSKEDCODE
			FROM #sTHETK#D
			WHERE PERSONNELIDNO = <cfqueryparam value="#PID#" cfsqltype="cf_sql_varchar">
			ORDER BY REFERENCEDATE
		</CFQUERY>
	<cfelse>
		<br /><br />
		<div align="center" style="font-family: Arial, Helvetica, sans-serif; font-size: 13px;">
			TK File does not exist on the database. <a href="../">Go Back.</a>
		</div>
		<cfabort>
	</CFIF>
	<cfquery name="qryworkskedcodes" dbtype="query">
		select distinct workskedcode
		from qryDETAILEDATTD
	</cfquery>
	<cfif qryworkskedcodes.recordcount>
		<cfquery name="qrywsdesc" datasource="#client.company_dsn#">
			select workskedcode, description
			from clkworksked
			where workskedcode in (<cfqueryparam value="#valuelist(qryworkskedcodes.workskedcode)#" list="yes" cfsqltype="cf_sql_varchar">)
		</cfquery>
	</cfif>
	<CFQUERY NAME = "qryEMPDETAILS" datasource="#CLIENT.COMPANY_DSN#">
		SELECT A.UNITCODE, A.PERSONNELBADGENO, A.LASTNAME, A.FIRSTNAME, 	
			A.MIDDLENAME,B.WORKSKEDCODE, C.DESCRIPTION, D.DESCRIPTION AS DEPTDESC
		FROM CMFPA A, CINWSMASTER B, CLKWORKSKED C, CLKDEPARTMENT D
		WHERE A.PERSONNELIDNO = B.PERSONNELIDNO
			AND B.ACTIVESKED = 'Y'
			AND B.WORKSKEDCODE = C.WORKSKEDCODE
			AND A.PERSONNELIDNO = <cfqueryparam value="#PID#" cfsqltype="cf_sql_varchar">
			AND A.DEPARTMENTCODE = D.DEPARTMENTCODE
	</CFQUERY>
	<CFQUERY name="qryVIEWER" datasource="#CLIENT.COMPANY_DSN#">
		SELECT #GETRECORD.GROUPCODE# FROM CMFPA
		WHERE PERSONNELIDNO = <cfqueryparam value="#CLIENT.CHAPA#" cfsqltype="cf_sql_varchar">
	</CFQUERY>
	<CFIF STDB NEQ "">
	<CFQUERY NAME = "qryDISTINCTREFDATE" dbtype="query">
		SELECT DISTINCT REFERENCEDATE FROM qryDETAILEDATTD
	</CFQUERY>
	<CFQUERY NAME = "qryATTDITEMCODES" dbtype="query">
		SELECT DISTINCT ITEMCODE FROM qryDETAILEDATTD
		WHERE ITEMCODE NOT IN ('HRWK','EB','LATE','UNDERTIME','EH','MB','NW','HOLLG')
	</CFQUERY>
	</CFIF>
	<!---<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
	<HTML>
	<HEAD>
		<TITLE>iBOS/e eDTR</TITLE>
		<CFOUTPUT>
		<LINK REL="StyleSheet" HREF="#client.wstheme_path##client.empcolor#.css" TYPE="text/css">
		</CFOUTPUT>
	</HEAD>
	<CFSET isCommand="">
	<BODY LEFTMARGIN=0 RIGHTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>--->
	
			<CFINCLUDE TEMPLATE="#client.common_path#_toggle.cfm">
			<!---<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" MODULE="#webCompCode#" COMPONENT="#getRECORD.EDTRGROUP#" LOCATION="../">--->
	<CFIF NOT STRUCTKEYEXISTS(FORM,"btnDOWNLOAD")  ><!---and NOT STRUCTKEYEXISTS(FORM,"btnViewAll")--->
			<TABLE BORDER="2" CELLPADDING="3" CELLSPACING="0" WIDTH="100%" >
			<CFOUTPUT>
				<cfif session.themessage neq "">
				<tr>
					<td><font color="FF0000" size="+1">#session.themessage#</font></td>
				</tr>
				</cfif>
				<tr>
					<td align="center" bgcolor="black">
						<font color="FFFFFF" size="+1"><b> #qryEMPDETAILS.LASTNAME#, #qryEMPDETAILS.FIRSTNAME# #qryEMPDETAILS.MIDDLENAME# </b></font>					</td>
				</tr>
			</TABLE>
			<!--- start of OT, Leaves etc --->
			<!--- Added by Teki 101911 to show hide OT Leaves etc. --->	
		<!---CFMODULE TEMPLATE="#client.common_path#cfm_wswindow3.cfm" TITLE="eDTR Related Transactions"--->
		<div id="readroot" style="overflow: auto;scrollbar-base-color:BLACK;scrollbar-arrow-color:WHITE;scrollbar-darkshadow-color:WHITE;scrollbar-highlight-color:WHITE;scrollbar-track-color:YELLOW;height: 200px;">
			
			<TABLE   CELLPADDING="2.5" BORDER="1" WIDTH="100%" id="filed" bgcolor="LIGHTGRAY" bordercolorlight="black" bordercolordark="white" style="border-bottom-color:white">
				<cfloop query="qryecrgforms">
					<cfset currentfc = formcode>
					<cfquery name="qrydatefield" dbtype="query">
						select datefield 
						from qryecrgdtrdtl 
						where formcode_fk = <cfqueryparam value="#formcode#" cfsqltype="cf_sql_varchar">
					</cfquery>
					<cfquery name="thefields" datasource="#client.global_dsn#">
						select columnname,columndesc,columntype
						from grgbosetablefields
						where tablename = <cfqueryparam value="#tablename_fk#" cfsqltype="cf_sql_varchar">
							and (isvisibleeform = 'Y'
							or isvisibleeform is null)
							and columnname not in ('reccreatedby','recdatecreated','userid','datelastupdate','timelastupdate','personnelidno','noofdays','toetype','approved','withpay')
						order by columnorder
					</cfquery>
					<CFQUERY NAME = "getCONTENTS" datasource="#CLIENT.COMPANY_DSN#">
						SELECT *
						FROM #tablename_fk#
						WHERE PERSONNELIDNO = <cfqueryparam value="#PID#" cfsqltype="cf_sql_varchar">
						<CFSET FIRST = TRUE>
						<CFSET WITHPREVIOUS = FALSE>
						<CFLOOP LIST = "#qrydatefield.datefield#" index="DF">
							<CFIF LISTFINDNOCASE(VALUELIST(thefields.COLUMNNAME),"#DF#") AND FIRST>
							AND(
							</CFIF>
							<CFIF LISTFINDNOCASE(VALUELIST(thefields.COLUMNNAME),"#DF#")>
								<CFIF WITHPREVIOUS>OR</CFIF>
							(#DF# >= '#dCUTOFFSTART#' AND #DF# <= '#dCUTOFFEND#')
								<CFSET WITHPREVIOUS = TRUE>
								<CFSET FIRST = FALSE>
							</CFIF>
						</CFLOOP>
						<CFIF NOT FIRST>)</CFIF>		
					</CFQUERY>
					<cfif getcontents.recordcount>
					<tr><td><cfmodule template="#client.common_path#cfm_group.cfm" caption="#description#"></td></tr>
					<tr><td bgcolor="black" style="color:Snow; font-size:regular; font-weight: bold" align="center">STATUS</td><!---<td align="center">&nbsp;</td>
--->

					<cfloop query="thefields">
						<td bgcolor="black" style="color:Snow; font-size:regular; font-weight: bold" align="center">#columndesc#</td>
					</cfloop>
					</tr>
					<cfset lstdocnums = "">
					<cfif thedocnumber neq "">
							<cfquery name="qryecindtrupdatedtl" datasource="#client.company_dsn#">
								select formcode_fk,docnumber_fk
								from ecindtrupdatedtl
								where docnumber = <cfqueryparam value="#thedocnumber#" cfsqltype="cf_sql_varchar">
									and formcode_fk = <cfqueryparam value="#currentfc#" cfsqltype="cf_sql_varchar">			
							</cfquery>
							<cfset lstdocnums = valuelist(qryecindtrupdatedtl.docnumber_fk)>
					</cfif>
					<cfloop query="getcontents">
						<cfset currentdc = docnumber>
						<cfset contentrow = currentrow>
						<!---<cftrace category="mico" var="lstdocnums">--->
						<tr>
						<cfswitch expression="#getcontents.approved[contentrow]#">
							<cfcase value="Y,C">
							<td align="center">	APPROVED </td><!---<td align="center">&nbsp;</td>--->
							</cfcase>
							<cfcase value="N">
							<td align="center">	DISAPPROVED </td><!---<td align="center">&nbsp;</td>--->
							</cfcase>
							<cfcase value="">
							<td align="center">	NOT YET ROUTED </td>
								<!---<td align="center"><cfif not edtrrouted and not structkeyexists(url,"eform")><cfif not listfindnocase(lstdocnums,"#currentdc#")>
								<form method="post"><input type="submit" value="include" name="btnlink"> 
								<input type="hidden" name="linkformcode" value="#currentfc#">
								<input type="hidden" name="linkdocnumber" value="#currentdc#">
								<input type="hidden" name="linkpid" value="#pid#"></form>
								<cfelse>
								<form method="post"><input type="submit" value="remove" name="btnremovelink"> 
								<input type="hidden" name="linkformcode" value="#currentfc#">
								<input type="hidden" name="linkdocnumber" value="#currentdc#">
								<input type="hidden" name="linkpid" value="#pid#"></form>
								</cfif></cfif></td>--->
							</cfcase>
							<cfdefaultcase>
							<td align="center">	PENDING </td><!---<td align="center"><cfif not edtrrouted and not structkeyexists(url,"eform")><cfif not listfindnocase(lstdocnums,"#currentdc#")><form method="post"><input type="submit" value="link" name="btnlink"> 
								<input type="hidden" name="linkformcode" value="currentfc">
								<input type="hidden" name="linkdocnumber" value="currentdc">
								<input type="hidden" name="linkpid" value="pid"></form>
								<cfelse>
								<form method="post"><input type="submit" value="remove" name="btnremovelink"> 
								<input type="hidden" name="linkformcode" value="currentfc">
								<input type="hidden" name="linkdocnumber" value="currentdc">
								<input type="hidden" name="linkpid" value="pid"></form>
								</cfif></cfif></td>--->
							</cfdefaultcase>				
						</cfswitch>
						
						<cfloop query="thefields">
							<td align="center">
							<cfif evaluate("getcontents.#columnname#[contentrow]") neq "">
								<cfif columntype neq "ftdatetime">
									#evaluate("getcontents.#columnname#[contentrow]")#
								<cfelse>
									#dateformat(evaluate("getcontents.#columnname#[contentrow]"))#
								</cfif>
							<cfelse>
								&nbsp;
							</cfif>							</td>
						</cfloop>
						</tr>
					</cfloop>
					</cfif>
				</cfloop>
			</TABLE>
		</div>
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">		
		<!--- End OT, Leaves etc.--->
			
			<!--- DAILY TIME RECORD	START --->
			<!--- <br> ---> 
			<TABLE align="center" BORDER="0" CELLPADDING="1" CELLSPACING="0" WIDTH="99%" >
				<!--- <tr height="10"></tr> --->
				<TR>
					<TD align="center" >
						<font color="000000" size="+2"><b>DAILY TIME RECORD</B>	</FONT>   </TD>
				</TR>
				<TR>
					<TD align="center">
						FROM &nbsp;&nbsp;<strong>#DATEFORMAT(dCUTOFFSTART, "mm/dd/yyyy")#</strong>&nbsp;&nbsp; 
						TO &nbsp;&nbsp;<strong>#DATEFORMAT(dCUTOFFEND, "mm/dd/yyyy")#</strong>					
					</TD>
				</TR>
				<TR>
					<TD align="left" >
						<strong>UNIT CODE:</strong> #qryEMPDETAILS.UNITCODE#	(#qryEMPDETAILS.DEPTDESC#)				</TD>
				</TR>
				<TR>
					<td align="left">
						<strong>EMPLOYEE NO.: </strong>#PID#					</td>
				</TR>
				<!---<TR>
					<td align="left">
						<strong>BADGE NO.:</strong> #qryEMPDETAILS.PERSONNELBADGENO#					</td>
				</TR>--->
				<TR>
					<TD align="left">
						<strong>EMPLOYEE NAME:</strong> #qryEMPDETAILS.LASTNAME#, #qryEMPDETAILS.FIRSTNAME# #qryEMPDETAILS.MIDDLENAME#					</TD>
				</TR>
				<TR>
					<TD align="left">
						<strong>SCHEDULE CODE:</strong> &nbsp;&nbsp;&nbsp;
						<cfif qryworkskedcodes.recordcount>
						<cfloop query="qrywsdesc">
						  #WORKSKEDCODE# (#DESCRIPTION#)&nbsp;&nbsp;&nbsp;
						</cfloop>
						</cfif>					</TD>
				</TR>
				<TR>
					<!---<TD align="left" colspan="15">
						==================================================================================================================================================================================================================
					</TD>--->
				</TR>
							<cfif not edtrrouted and ( (fieldisupdate eq "Y" and pid eq client.chapa) or (masterupdate eq "Y" and pid eq client.chapa) or masterupdategroup eq "Y" or fieldisupdategroup eq "Y" )>
				<!---><br /><select name="selapp">
					<cfif listfindnocase(valuelist(qryecrgdtrdtl.formcode_fk),"PX") and listfindnocase(valuelist(qryPX.referencedate),"#qryREFDATE.REFERENCEDATE#")>
						<option value="#getrecord.tkfilename_fk#PX">Attendance Exception</option>
					</cfif>--->
					<script type="text/javascript">
							function openeForm(sURL) {window.open("sURL","MASTER","width=700,height=530,ScrollBars=yes,Resizable=Yes");" }
					</script>
					
					<cfloop query="qryecrgforms"><!---><option value="#tablename_fk#">#description#</option>--->
<!--- 							<CFQUERY NAME="getROUTINGFORM#currentrow#" DATASOURCE="#CLIENT.COMPANY_DSN#">
								SELECT FORMCODE, TEMPLATECODE_FK 
								FROM ECRGFORMS <!---WITH (NOLOCK)--->
								WHERE TABLENAME_FK = '#tablename#'
							</CFQUERY> --->
							<CFQUERY NAME="getROUTINGFORMTEMPLATE" DATASOURCE="#CLIENT.GLOBAL_DSN#">
								SELECT TEMPLATEPATH 
								FROM EGRGTEMPLATES <!---WITH (NOLOCK)--->
								WHERE TEMPLATECODE = '#TEMPLATECODE_FK#'
							</CFQUERY>
							<CFIF getROUTINGFORMTEMPLATE.recordcount and not edtrrouted>
								<CFPARAM NAME = "sMESS" default="">
								<cfset session.tablocation = "../../edtr/">
								<CFSET sAnchor = "?id=" & "#URLENCODEDFORMAT(encrypt("#FORMCODE#", client.ek))#">
								<CFSET surl="#CLIENT.DOMAIN##getROUTINGFORMTEMPLATE.TEMPLATEPATH##sAnchor#">
						<!--- 	<cfelse>
								<cfset session.themessage = "You have an eDTR updating form that is currently on-process. <br /> It has to be acted upon first before you can route another one for this attendance cut-off."> --->
							<cfoutput>
								<tr><td><a href="#sURL#" target="_blank" onClick="javascript: openeForm('#sURL#');return true;" >#description#</a></td></tr>
							</cfoutput>
									
							</CFIF>
					</cfloop>
					
					<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTTAB"
							USERFIELD = "USERGRPID_FK" RECORDFIELD = "TABID">
							
					<cfif listFind(quotedUserRecords, "'worksched'", ",") neq 0>
						<cfoutput>
							<tr>
								<td>
									<a href="#client.domain#eworksched" target="_blank" 
										onClick="javascript: openeForm('#client.domain#eworksched')">Change Work Schedule</a>
										
								</td>
							</tr>
						</cfoutput>
					</cfif>
					<!---</select><input name="btngo" value="Add" type="submit"> 
					<input type="hidden" value="#refdate#" name="refdate">--->
			</cfif>
				</TABLE>
				<!--- Removed by Teki 10/19/2011 bordercolorlight="white" bordercolordark="white" --->
			<!--- <div id="readroot2" class="TableContainer" style="overflow: auto;height: 600px;">	--->
		
			<!---<div id="readroot" style="overflow: auto;scrollbar-base-color:BLACK;scrollbar-arrow-color:WHITE;scrollbar-darkshadow-color:WHITE;scrollbar-highlight-color:WHITE;scrollbar-track-color:YELLOW;height: 200px;">	--->
			<TABLE NAME="MYTABLE" class="scrollTable"  border="1" CELLPADDING="3" CELLSPACING="0" WIDTH="99%" align="center" border-collapse="collapse" bordercolorlight="Ivory" bordercolordark="Ivory" bgcolor="Lavender" >
	
  <!---<thead class="fixedHeader headerFormat">--->

				 <!---<TR height="10">
				 <TD width="13%">&nbsp;</TD>
				  <TD width="12%">&nbsp;</TD>
				  <TD width="7%">&nbsp;</TD>
				  <TD width="9%">&nbsp;</TD>
				  <TD colspan="2"><div align="center">SCHEDULE</div></TD>
				  <TD colspan="2"><div align="center">ACTUAL</div></TD>
				  <TD width="6%">&nbsp;</TD>
				  <TD width="2%">&nbsp;</TD>
				  </TR>--->
				<TR>
		
					<TD align="center" width="5%" bordercolor="WHITE" bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold">
						<strong>SCHEDULE CODE</strong>
					</TD>
					<TD align="center" width="5%"  bordercolor="WHITE" bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold">
						<strong>REFERENCE DATE</strong>
					</TD>
					<TD bgcolor="CC0000" width="3%"bordercolor="WHITE">
						<div align="center"  width="3%" style="color:Snow; font-size:regular; font-weight: bold"><strong>DAY</strong></div>
					</TD>
					<TD bgcolor="CC0000" bordercolor="WHITE">
						<div align="center" style="color:Snow; font-size:regular; font-weight: bold"><strong>DAY TYPE</strong></div>
					</TD>
					<!---TD><div align="center">SCHEDULED IN</div></TD---><!---TD><div align="center">SCHEDULED OUT</div></TD--->
					<TD bgcolor="CC0000" bordercolor="WHITE">
						<div align="center" style="color:Snow; font-size:regular; font-weight: bold"><strong>ACTUAL IN</strong></div>
					</TD>
					<TD bgcolor="CC0000" bordercolor="WHITE">
						<div align="center" style="color:Snow; font-size:regular; font-weight: bold"><strong>ACTUAL OUT</strong></div>
					</TD bgcolor="black" >
					<TD bgcolor="black" bordercolor="WHITE">
						<div align="center" style="color:Snow; font-size:regular; font-weight: bold"><strong>HRWK</strong></div>
					</TD>
					
					<!---mico05042010<CFSET lstITEMCODES = "">--->
					<cfset arritemcodes = arraynew(1)>
					<CFIF STDB NEQ "">
					<CFLOOP query="qryATTDITEMCODES">
						<!---mico05042010<CFSET lstITEMCODES = LISTAPPEND(lstITEMCODES,ITEMCODE)>--->
						<cfset arritemcodes[currentrow] = itemcode>
						<TD bgcolor="black" bordercolor="WHITE"><div align="center" style="background-color:black; color:Snow; font-size:regular; font-weight: bold" ><strong>#ITEMCODE#</strong></div></TD>
						<CFSET "#ITEMCODE#" = 0>
					</CFLOOP>
				
				</TR>
		<!---  </thead>	--->	
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================				</TD>
			
			</TR>--->
		
		
		
			<CFSET nTOTALHRWK = 0>
			<cfquery name="qryPX" datasource="#sTDB#">
				select personnelidno,referencedate from #sthetk#PX
				where personnelidno = <cfqueryparam value="#pid#" cfsqltype="cf_sql_varchar">
					and remarks = 'PAIRU'
			</cfquery><!---<cftrace category="edtrrouted" var="edtrrouted">--->
	
			<CFLOOP query="qryDISTINCTREFDATE">
				<CFQUERY NAME = "qryREFDATE" dbtype="query">
					SELECT *
					FROM qryDETAILEDATTD
					WHERE REFERENCEDATE = '#REFERENCEDATE#'
				</CFQUERY>
				<!---mico05042010<CFSET lstcodevaluepair = "">--->
				<cfset arrcodevaluepair = arraynew(2)>
				<CFLOOP QUERY = "qryREFDATE">
					<!---mico05042010<CFSET lstCODEVALUEPAIR = LISTAPPEND(lstCODEVALUEPAIR,"#ITEMCODE#@#ITEMVALUE#")>--->
					<cfset arrcodevaluepair[currentrow][1] = itemcode>
					<cfset arrcodevaluepair[currentrow][2] = itemvalue>
				</CFLOOP>
				<CFSET ATTDROW = CURRENTROW>
				<cfset refdate = DATEFORMAT(qryREFDATE.REFERENCEDATE,"mm/dd/yyyy")>
				<form name="frmviewedtr" method="post" <!---action="./update.cfm?id=#urlencodedformat(encrypt(sedtrcode,client.ek))#&pid=#urlencodedformat(encrypt(pid,client.ek))#&newapp=1"--->>
				<TR>
					
					<TD width="5%" ><input type="hidden" value="#pid#" name="formpid" />
						<div align="center" width="5%" >#qryREFDATE.WORKSKEDCODE#</div>
					</TD>
					<TD align="center" width="5%">#DATEFORMAT(qryREFDATE.REFERENCEDATE, "mm/dd/yyyy")#
					
					<!---mico 09162010<cfif not edtrrouted and ( (fieldisupdate eq "Y" and pid eq client.chapa) or (masterupdate eq "Y" and pid eq client.chapa) or masterupdategroup eq "Y" or fieldisupdategroup eq "Y" )><br /><select name="selapp"><cfif listfindnocase(valuelist(qryecrgdtrdtl.formcode_fk),"PX") and listfindnocase(valuelist(qryPX.referencedate),"#qryREFDATE.REFERENCEDATE#")><option value="#getrecord.tkfilename_fk#PX">Attendance Exception</option></cfif><cfloop query="qryecrgforms"><option value="#tablename_fk#">#description#</option></cfloop></select><input name="btngo" value="Add" type="submit"> <input type="hidden" value="#refdate#" name="refdate"></cfif>--->
					
					</TD>
					<TD width="3%"> 
						<!--- <div align="center">#DayofWeekAsString(DayOfWeek(qryREFDATE.REFERENCEDATE))# </div> --->
						<div align="center">#uCase(Left(DayofWeekAsString(DayOfWeek(qryREFDATE.REFERENCEDATE)), 3))#</div>
					</TD>
					<TD width="3%"> <div align="center">#qryREFDATE.DAYTYPE# </div></TD>
				  <!---TD width="5%"><cfif qryREFDATE.SKEDIN neq ""> <div align="center">#qryREFDATE.SKEDIN# </div><cfelse> &nbsp;</cfif></TD--->
				  <!---TD width="5%"><cfif qryREFDATE.SKEDOUT neq ""> <div align="center">#qryREFDATE.SKEDOUT# </div><cfelse>&nbsp;</cfif></TD--->
				  <TD width="5%"><cfif qryREFDATE.ACTUALIN neq ""><div align="center">#qryREFDATE.ACTUALIN# </div><cfelse>&nbsp;</cfif></TD>
				  <TD width="5%"><cfif qryREFDATE.ACTUALOUT neq ""><div align="center">#qryREFDATE.ACTUALOUT#</div><cfelse>&nbsp;</cfif></TD>
						<CFSET WITHHRWK = FALSE>				 
						<!---mico05042010<CFLOOP LIST = "#lstCODEVALUEPAIR#" index="CVP">--->
						<cfloop from="1" to="#arraylen(arrcodevaluepair)#" index="x">
							<!---mico05042010<CFIF LISTGETAT(#CVP#,1,"@") EQ "HRWK">--->
							<cfif arrcodevaluepair[x][1] eq "HRWK">
								<!---MICO05042010<TD width="5%"><div align="center">#LISTGETAT(CVP,2,"@")# </div></TD>--->
								<TD width="5%"><div align="center">#arrcodevaluepair[x][2]# </div></TD>
								<CFSET WITHHRWK = TRUE>
								<!---mico05042010<CFSET nTOTALHRWK = nTOTALHRWK + LISTGETAT(CVP,2,"@")>--->
								<CFSET nTOTALHRWK = nTOTALHRWK + arrcodevaluepair[x][2]>								
							</CFIF>
						</CFLOOP>
						<CFIF NOT WITHHRWK>
							<TD width="5%"><div align="center">&nbsp;</div></TD>
						</CFIF>
						<!---mico05042010<CFLOOP LIST = "#lstITEMCODES#" index="IC">--->
						<cfloop from="1" to="#arraylen(arritemcodes)#" index="a">
							<cfset IC = arritemcodes[a]>
							<CFSET ITEMCODEFOUND = FALSE>
							<!---mico05042010<CFLOOP LIST = "#lstCODEVALUEPAIR#" INDEX = "CVP">--->
							<cfloop from="1" to="#arraylen(arrcodevaluepair)#" index="b">
								<!---mico05042010<CFIF LISTGETAT(#CVP#,1,"@") EQ IC>--->
								<cfif arrcodevaluepair[b][1] eq IC>
								  <!---mico05042010<TD width="5%"><div align="center">#LISTGETAT(CVP,2,"@")# </div></TD>--->
								  	<TD width="5%"><div align="center">#arrcodevaluepair[b][2]# </div></TD>
									<!---mico05042010<CFSET THIS = LISTGETAT(#CVP#,1,"@")>--->
									<CFSET THIS = arrcodevaluepair[b][1]>
									<CFSET ITEMCODEFOUND = TRUE>
									<!---mico05042010<CFSET "#THIS#" = EVALUATE("#THIS#") + LISTGETAT(CVP,2,"@")>--->
									<CFSET "#THIS#" = EVALUATE("#THIS#") + arrcodevaluepair[b][2]>
								</CFIF>
							</CFLOOP>
							<CFIF NOT ITEMCODEFOUND>
							  <TD width="5%"><div align="center">&nbsp;</div></TD>
							</CFIF>
						</CFLOOP>
				</TR></form>
			</CFLOOP>
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================			</TD>
				</TR>--->
				<TR>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER"><strong>TOTAL:</strong></div></TD>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER">&nbsp;</div></TD>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER">&nbsp;</div></TD>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER">&nbsp;</div></TD>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER">&nbsp;</div></TD>
					<TD bgcolor="CC0000" style="color:Snow; font-size:regular; font-weight: bold"><div align="CENTER">&nbsp;</div></TD>
					<TD bgcolor="black" style="color:Snow; font-size:regular; font-weight: bold"> <div align="center"><strong>#NumberFormat(nTOTALHRWK, "999,999,999.99")#</strong></div></TD>
					<!---mico05042010<CFLOOP list="#lstITEMCODES#" index="IC">--->
					<cfloop from="1" to="#arraylen(arritemcodes)#" index="c">
						<!---mico05042010<TD><div align="center"> #EVALUATE("#IC#")# </div></TD>--->
						<TD bgcolor="black" style="color:Snow; font-size:regular; font-weight: bold">
							<div align="center"><strong>#NumberFormat(evaluate("#arritemcodes[c]#"), "999,999,999.99")#</strong></div>
						</TD>
					</CFLOOP>
				</TR>
				<!--- <tr height="10"></tr> --->
			</table>
		</div>
				<table cellspacing="7">
				<TR>
					<TD> <strong>LEGEND:</strong> </TD>
				</TR>
				<CFQUERY NAME = "qryCLKPYITEMS" datasource="#CLIENT.COMPANY_DSN#">
					SELECT PYITEMCODE, PYITEMDESCRIPTION FROM CLKPYITEMS
					WHERE PYITEMCODE IN ('HRWK'<CFIF qryATTDITEMCODES.RECORDCOUNT>,#QUOTEDVALUELIST(qryATTDITEMCODES.ITEMCODE)#</CFIF>)
				</CFQUERY>
				<TR>
				<CFLOOP QUERY = "qryCLKPYITEMS">
					<CFIF CURRENTROW MOD 4>
					<TD> <strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION# </TD>
					<CFELSE>
					</TR>
					<TR>
					<TD> <strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION# </TD>
					</TR></CFIF>
				</CFLOOP>
				<CFELSE>
					<span style="font-family: sans-serif;
								font-size: 12px;
								color: ##FF0000;">
					TK File Not Found.
					</span>
				</CFIF>
				</TABLE>
			</CFOUTPUT>
	<!---<CFELSEIF STRUCTKEYEXISTS(FORM,"btnViewAll")>--->
		<!---
		<CFMODULE TEMPLATE="#client.common_path#cfm_geturlvariables.cfm">
		<cflocation url="#clien"
		<INPUT type="hidden"  name="sID" VALUE = "#sEDTRCODE#">
			<INPUT type="hidden"  name="GROUPCODE" VALUE = "#getRECORD.GROUPCODE#">
			<INPUT type="hidden"  name="GROUPCODEVAL" VALUE = "#EVALUATE("QRYVIEWER."&GETRECORD.GROUPCODE)#" >--->
	<CFELSEIF FORM.selEXTRACTTYPE EQ "excel" and pid eq form.hiddownloadpid>
		<cfheader name="Content-Disposition" value="attachment; filename=#PID#-eDTR.xls">
		<cfcontent type="application/vnd.ms-excel">
		<cfoutput>
		<TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="100%" >
				<!--- <tr height="10"></tr> --->
				<TR>
					<TD align="center" colspan="#qryATTDITEMCODES.RecordCount + 7#" >
						DAILY TIME RECORD					
					</TD>
				</TR>
				<TR>
					<TD align="center" colspan="#qryATTDITEMCODES.RecordCount + 7#" >
						FROM &nbsp;&nbsp;#DATEFORMAT(dCUTOFFSTART, "mm/dd/yyyy")# &nbsp;&nbsp;
						TO &nbsp;&nbsp;#DATEFORMAT(dCUTOFFEND, "mm/dd/yyyy")#
						</TD>
				</TR>
				<TR>
					<TD align="left" colspan="4">
						<strong>UNIT CODE:</strong> #qryEMPDETAILS.UNITCODE# (#qryEMPDETAILS.DEPTDESC#)				
					</TD>
				</TR>
				<TR>
					<td align="left" colspan="4">
						<strong>EMPLOYEE NO.:</strong> #PID#					</td>
				</TR>
			<!---	<TR>
					<td align="left" colspan="4">
						<strong>BADGE NO.:</strong> #qryEMPDETAILS.PERSONNELBADGENO#					</td>
				</TR> --->
				<TR>
					<TD align="left" colspan="4">
						<strong>EMPLOYEE NAME:</strong> #qryEMPDETAILS.LASTNAME#, #qryEMPDETAILS.FIRSTNAME# #qryEMPDETAILS.MIDDLENAME#					</TD>
				</TR>
				<TR>
					<TD align="left" colspan="4">
						<strong>SCHEDULE CODE:</strong> &nbsp;&nbsp;&nbsp;
						<cfif qryworkskedcodes.recordcount>
						<cfloop query="qrywsdesc">
						  #WORKSKEDCODE# (#DESCRIPTION#)&nbsp;&nbsp;&nbsp;
						</cfloop>
						</cfif>					</TD>
				</TR>
				<TR>
					<!---<TD align="left" colspan="15">
						==================================================================================================================================================================================================================
					</TD>--->
				</TR>
				</TABLE>
				<TABLE border="2" <!--- bordercolorlight="white" bordercolordark="white" style="border-bottom-color:white" --->
					 CELLPADDING="3" CELLSPACING="0" WIDTH="100%" >
				<TR height="10">
				  <!---<TD width="13%">&nbsp;</TD>
				  <TD width="12%">&nbsp;</TD>
				  <TD width="7%">&nbsp;</TD>
				  <TD width="9%">&nbsp;</TD>
				  <TD colspan="2"><div align="center">SCHEDULE</div></TD>
				  <TD colspan="2"><div align="center">ACTUAL</div></TD>
				  <TD width="6%">&nbsp;</TD>
				  <TD width="2%">&nbsp;</TD>
				  </TR>--->
				<TR>
					<TD WIDTH="10px"><div align="center">SKED CODE</div></TD>
					<TD bordercolor="red" align="center">REFERENCE DATE</TD>
					<TD><div align="center">DAY</div></TD>
					<TD><div align="center">DAY TYPE</div></TD>
					<!--- <TD><div align="center">SCHEDULED IN</div></TD> --->
					<!--- <TD><div align="center">SCHEDULED OUT</div></TD> --->
					<TD><div align="center">ACTUAL IN</div></TD>
					<TD><div align="center">ACTUAL OUT</div></TD>
					<TD><div align="center">HRWK</div></TD>
					<CFSET lstITEMCODES = "">
					<CFIF STDB NEQ "">
					<CFLOOP query="qryATTDITEMCODES">
						<CFSET lstITEMCODES = LISTAPPEND(lstITEMCODES,ITEMCODE)>
						<TD><div align="center">#ITEMCODE#</div></TD>
						<CFSET "#ITEMCODE#" = 0>
					</CFLOOP>
				</TR>
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================				</TD>
				</TR>--->
			<CFSET nTOTALHRWK = 0>
			<cfquery name="qryPX" datasource="#sTDB#">
				select personnelidno,referencedate from #sthetk#PX
				where personnelidno = '#pid#'
					and remarks = 'PAIRU'
			</cfquery>
			<CFLOOP query="qryDISTINCTREFDATE">
				<CFQUERY NAME = "qryREFDATE" dbtype="query">
					SELECT *
					FROM qryDETAILEDATTD
					WHERE REFERENCEDATE = '#REFERENCEDATE#'
				</CFQUERY>
				<CFSET lstcodevaluepair = "">
				<CFLOOP QUERY = "qryREFDATE">
					<CFSET lstCODEVALUEPAIR = LISTAPPEND(lstCODEVALUEPAIR,"#ITEMCODE#@#ITEMVALUE#")>
				</CFLOOP>
				<CFSET ATTDROW = CURRENTROW>
				<cfset refdate = DATEFORMAT(qryREFDATE.REFERENCEDATE,"mm/dd/yyyy")>
				<form name="frmviewedtr" method="post" action="./update.cfm?id=#urlencodedformat(encrypt(sedtrcode,client.ek))#&pid=#urlencodedformat(encrypt(pid,client.ek))#&newapp=1">
				<TR>
					<TD> <div align="center">#qryREFDATE.WORKSKEDCODE#</div></TD>
					<TD align="center" width="25%">#DATEFORMAT(qryREFDATE.REFERENCEDATE, "mm/dd/yyyy")#</TD>
					<TD width="5%"> <div align="center">#Left(DayofWeekAsString(DayOfWeek(qryREFDATE.REFERENCEDATE)), 3)# </div></TD>
					<TD width="5%"> <div align="center">#qryREFDATE.DAYTYPE# </div></TD>
				 <!--- <TD width="5%"> <div align="center">#qryREFDATE.SKEDIN# </div></TD> --->
				 <!--- <TD width="5%"> <div align="center">#qryREFDATE.SKEDOUT# </div></TD> --->
				  <TD width="5%"> <div align="center">#qryREFDATE.ACTUALIN# </div></TD>
				  <TD width="5%"> <div align="center">#qryREFDATE.ACTUALOUT#</div></TD>
						<CFSET WITHHRWK = FALSE>				 
						<CFLOOP LIST = "#lstCODEVALUEPAIR#" index="CVP">
							<CFIF LISTGETAT(#CVP#,1,"@") EQ "HRWK">
								<TD width="5%"><div align="center">#LISTGETAT(CVP,2,"@")# </div></TD>
								<CFSET WITHHRWK = TRUE>
								<CFSET nTOTALHRWK = nTOTALHRWK + LISTGETAT(CVP,2,"@")>
							</CFIF>
						</CFLOOP>
						<CFIF NOT WITHHRWK>
							<TD width="5%"><div align="center"></div></TD>
						</CFIF>
						<CFLOOP LIST = "#lstITEMCODES#" index="IC">
							<CFSET ITEMCODEFOUND = FALSE>
							<CFLOOP LIST = "#lstCODEVALUEPAIR#" INDEX = "CVP">
								<CFIF LISTGETAT(#CVP#,1,"@") EQ IC>
								  <TD width="5%"><div align="center">#LISTGETAT(CVP,2,"@")# </div></TD>
									<CFSET THIS = LISTGETAT(#CVP#,1,"@")>
									<CFSET ITEMCODEFOUND = TRUE>
									<CFSET "#THIS#" = EVALUATE("#THIS#") + LISTGETAT(CVP,2,"@")>
								</CFIF>
							</CFLOOP>
							<CFIF NOT ITEMCODEFOUND>
							  <TD width="5%"><div align="center"></div></TD>
							</CFIF>
						</CFLOOP>
				</TR></form>
			</CFLOOP>
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================			</TD>
				</TR>--->
				<TR>
					<TD width="10px"><div align="CENTER"><strong>TOTAL:</strong></div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<!--- <TD><div align="CENTER">&nbsp;</div></TD> --->
					<!--- <TD><div align="CENTER">&nbsp;</div></TD> --->
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD> <div align="center"><strong>#NumberFormat(nTOTALHRWK, "999,999,999.99")#</strong></div></TD>
					<CFLOOP list="#lstITEMCODES#" index="IC">
						<TD><div align="center"><strong>#NumberFormat(EVALUATE("#IC#"), "999,999,999.99")#</strong></div></TD>
					</CFLOOP>
				</TR>
				<TR>
					<TD colspan="#qryATTDITEMCODE.RecordCount + 7#" ><strong> LEGEND:</strong> </TD>
				</TR>
				<CFQUERY NAME = "qryCLKPYITEMS" datasource="#CLIENT.COMPANY_DSN#">
					SELECT PYITEMCODE, PYITEMDESCRIPTION FROM CLKPYITEMS
					WHERE PYITEMCODE IN ('HRWK'<CFIF qryATTDITEMCODES.RECORDCOUNT>,#QUOTEDVALUELIST(qryATTDITEMCODES.ITEMCODE)#</CFIF>)
				</CFQUERY>
				<TR>
				<CFLOOP QUERY = "qryCLKPYITEMS">
					<CFIF CURRENTROW MOD 4>
					<TD colspan="4" id="leg"><strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION#</TD>
					<CFELSE>
					</TR>
					<TR>
					<TD colspan="4" id="leg"><strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION#</TD>
					</TR></CFIF>
				</CFLOOP>
				<CFELSE>
					TK FILE NOT FOUND.
				</CFIF>
					<TR>
						<TD colspan="#qryATTDITEMCODES.RecordCount + 7#" align="center">
							Downloaded eDTR by #CLIENT.MYNAME# on #dateformat(now(), "mmm dd, yyyy")# #timeformat(now())#.
						</TD>
					</TR>
				</TABLE>
			</CFOUTPUT>
		<cfabort>
	<CFELSEIF FORM.selEXTRACTTYPE EQ "pdfPortrait"  OR FORM.selEXTRACTTYPE EQ "pdfLandscapeLong" and pid eq form.hiddownloadpid>
	<CFSET REPLACEFN = #REReplace(sTHETK,"TO",".","ALL")#>
	<CFSET RIGHTFN = #RIGHT(REPLACEFN,14)#>
	<CFSET NEWFN = #REReplace(RIGHTFN,"_",".","ALL")#>
	<CFSET MM = #TIMEFORMAT(NOW(),'mmss')#>
	<cfheader name="Content-Disposition" value="attachment; filename=#qryEMPDETAILS.UNITCODE#-#PID#-#NEWFN#-#MM#.pdf">
	<cfcontent type="application/pdf">
	<!--- portrait 
	<cfdocument format="pdf" marginLeft = ".1"  marginRight = ".1" >--->
	<!--- Landscape --->
	 <cfif FORM.selEXTRACTTYPE EQ "pdfPortrait">
		 <cfset orientation = "portrait">
		 <cfset pType = "letter">
	 <cfelse>
		 <cfset orientation = "landscape">
		 <cfset pType = "legal">
	  </cfif>
	 <CFOUTPUT>
	<cfdocument format="pdf" marginLeft = ".1"  marginRight = ".1" marginTop = ".1" marginBottom = ".1" orientation = "#orientation#" pageType="#pType#">
	<html>
	<head>
		<style type="text/css">
			body, table, tr, td
			{
				font-size: 8px;
			}
			.leg
			{
				font-size: 4px;
			}
		</style>
	</head>

		<body>
		<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" WIDTH="100%">
			
			<TR>
				<TD width="10">
					<IMG SRC="#client.image_path##session.site_ibose#" width="50">
				</td>
				<td>
					<FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><br /> iBOS/e eDTR
				</TD>
			</TR>
	</TABLE>
		<TABLE BORDER="0" CELLPADDING="1" CELLSPACING="0" WIDTH="100%" >
				<!--- <tr height="10"></tr> --->
				<TR>
					<TD align="center" >
						DAILY TIME RECORD					
					</TD>
				</TR>
				<TR>
					<TD align="center">
						FROM &nbsp;&nbsp;#DATEFORMAT(dCUTOFFSTART, "mm/dd/yyyy")#&nbsp;&nbsp;
						TO &nbsp;&nbsp;#DATEFORMAT(dCUTOFFEND, "mm/dd/yyyy")#					
					</TD>
				</TR>
				<TR>
					<TD align="left">
						<strong>UNIT CODE:</strong> #qryEMPDETAILS.UNITCODE# (#qryEMPDETAILS.DEPTDESC#)
					</TD>
				</TR>
				<TR>
					<td align="left">
						<strong>EMPLOYEE NO.:</strong> #PID#
					</td>
				</TR>
				<!---<TR>
					<td align="left">
						<strong>BADGE NO.:</strong> #qryEMPDETAILS.PERSONNELBADGENO#					</td>
				</TR> --->
				<TR>
					<TD align="left">
						<strong>EMPLOYEE NAME:</strong> #qryEMPDETAILS.LASTNAME#, #qryEMPDETAILS.FIRSTNAME# #qryEMPDETAILS.MIDDLENAME#					</TD>
				</TR>
				<TR>
					<TD align="left">
						<strong>SCHEDULE CODE:</strong> &nbsp;&nbsp;&nbsp;
						<cfif qryworkskedcodes.recordcount>
						<cfloop query="qrywsdesc">
						  #WORKSKEDCODE# (#DESCRIPTION#)&nbsp;&nbsp;&nbsp;
						</cfloop>
						</cfif>					
					</TD>
				</TR>
				<TR>
					<!---<TD align="left" colspan="15">
						==================================================================================================================================================================================================================
					</TD>--->
				</TR>
				</TABLE>
				<TABLE border="1" <!--- bordercolorlight="white" bordercolordark="white" style="border-bottom-color:white" ---> 
					CELLPADDING="1" CELLSPACING="0" WIDTH="100%" style="table-layout: fixed;">
				 <!---<TR height="10">
				 <TD width="13%">&nbsp;</TD>
				  <TD width="12%">&nbsp;</TD>
				  <TD width="7%">&nbsp;</TD>
				  <TD width="9%">&nbsp;</TD>
				  <TD colspan="2"><div align="center">SCHEDULE</div></TD>
				  <TD colspan="2"><div align="center">ACTUAL</div></TD>
				  <TD width="6%">&nbsp;</TD>
				  <TD width="2%">&nbsp;</TD>
				  </TR>--->
				<TR>
					<TD align="center" width="1%" style="font-size: 8px;">SKED CODE</TD>
					<TD bordercolor="red" align="center" width="1%" style="font-size: 8px;">REF DATE</TD>
					
					<TD><div align="center" width="1%" style="font-size: 8px;">DAY TYPE</div></TD>
					<!--- <TD><div align="center">SCHEDULED IN</div></TD> --->
					<!--- <TD><div align="center">SCHEDULED OUT</div></TD> --->
					<TD><div align="center" width="1%" style="font-size: 8px;">ACTUAL IN</div></TD>
					<TD><div align="center" width="1%" style="font-size: 8px;">ACTUAL OUT</div></TD>
					<TD><div align="center" width="1%" style="font-size: 8px;">HRWK</div></TD>
					<CFSET lstITEMCODES = "">
					<CFIF STDB NEQ "">
					<CFLOOP query="qryATTDITEMCODES">
						<CFSET lstITEMCODES = LISTAPPEND(lstITEMCODES,ITEMCODE)>
						<TD><div align="center" width="1" style="font-size: 8px; word-wrap: break-word;">#ITEMCODE#</div></TD>
						<CFSET "#ITEMCODE#" = 0>
					</CFLOOP>
				</TR>
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================				</TD>
				</TR>--->
			<CFSET nTOTALHRWK = 0>
			<cfquery name="qryPX" datasource="#sTDB#">
				select personnelidno,referencedate from #sthetk#PX
				where personnelidno = '#pid#'
					and remarks = 'PAIRU'
			</cfquery>
			<CFLOOP query="qryDISTINCTREFDATE">
				<CFQUERY NAME = "qryREFDATE" dbtype="query">
					SELECT *
					FROM qryDETAILEDATTD
					WHERE REFERENCEDATE = '#REFERENCEDATE#'
				</CFQUERY>
				<CFSET lstcodevaluepair = "">
				<CFLOOP QUERY = "qryREFDATE">
					<CFSET lstCODEVALUEPAIR = LISTAPPEND(lstCODEVALUEPAIR,"#ITEMCODE#@#ITEMVALUE#")>
				</CFLOOP>
				<CFSET ATTDROW = CURRENTROW>
				<cfset refdate = DATEFORMAT(qryREFDATE.REFERENCEDATE,"mm/dd/yyyy")>
				<form name="frmviewedtr" method="post" action="./update.cfm?id=#urlencodedformat(encrypt(sedtrcode,client.ek))#&pid=#urlencodedformat(encrypt(pid,client.ek))#&newapp=1">
				<TR>
					<TD> <div align="center" style="font-size: 8px;">#qryREFDATE.WORKSKEDCODE#</div></TD>
					<TD align="center" style="font-size: 8px;">#DATEFORMAT(qryREFDATE.REFERENCEDATE, "mm/dd/yy")#-#Left(DayofWeekAsString(DayOfWeek(qryREFDATE.REFERENCEDATE)), 3)#</TD>
					<!---<TD width="1%"> <div align="center" style="font-size: 8px;"></div></TD>--->
					<TD width="1%"> <div align="center" style="font-size: 8px;">#qryREFDATE.DAYTYPE# </div></TD>
				 <!--- <TD width="5%"> <div align="center">#qryREFDATE.SKEDIN# </div></TD> --->
				 <!--- <TD width="5%"> <div align="center">#qryREFDATE.SKEDOUT# </div></TD> --->
				  <TD width="1%"> <div align="center" style="font-size: 8px;">#qryREFDATE.ACTUALIN# </div></TD>
				  <TD width="1%"> <div align="center" style="font-size: 8px;">#qryREFDATE.ACTUALOUT#</div></TD>
						<CFSET WITHHRWK = FALSE>				 
						<CFLOOP LIST = "#lstCODEVALUEPAIR#" index="CVP">
							<CFIF LISTGETAT(#CVP#,1,"@") EQ "HRWK">
								<TD width="1%"><div align="center" style="font-size: 8px;">#LISTGETAT(CVP,2,"@")# </div></TD>
								<CFSET WITHHRWK = TRUE>
								<CFSET nTOTALHRWK = nTOTALHRWK + LISTGETAT(CVP,2,"@")>
							</CFIF>
						</CFLOOP>
						<CFIF NOT WITHHRWK>
							<TD width="1%"><div align="center"></div></TD>
						</CFIF>
						<CFLOOP LIST = "#lstITEMCODES#" index="IC">
							<CFSET ITEMCODEFOUND = FALSE>
							<CFLOOP LIST = "#lstCODEVALUEPAIR#" INDEX = "CVP">
								<CFIF LISTGETAT(#CVP#,1,"@") EQ IC>
								<!--- Value of PDF table --->
								  <TD width="1%"><div align="center">#LISTGETAT(CVP,2,"@")# </div></TD>
									<CFSET THIS = LISTGETAT(#CVP#,1,"@")>
									<CFSET ITEMCODEFOUND = TRUE>
									<CFSET "#THIS#" = EVALUATE("#THIS#") + LISTGETAT(CVP,2,"@")>
									
								</CFIF>
							</CFLOOP>
							<CFIF NOT ITEMCODEFOUND>
							  <TD width="1%"><div align="center"></div></TD>
							</CFIF>
						</CFLOOP>
				</TR></form>
			</CFLOOP>
				<!---<TR>
					<TD align="left" colspan="15">
					==================================================================================================================================================================================================================			</TD>
				</TR>--->
				<TR>
					<TD width="1%" colspan="2"><div align="CENTER"><strong>TOTAL:</strong></div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<!--- <TD><div align="CENTER">&nbsp;</div></TD> --->
					<!--- <TD><div align="CENTER">&nbsp;</div></TD> --->
					<!--- <TD><div align="CENTER">&nbsp;</div></TD> --->
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD><div align="CENTER">&nbsp;</div></TD>
					<TD> <div align="center"><strong>#NumberFormat(nTOTALHRWK, "999,999,999.99")#</strong></div></TD>
					<CFLOOP list="#lstITEMCODES#" index="IC">
						<TD><div align="center"><strong>#NumberFormat(EVALUATE("#IC#"), "999,999,999.99")#</strong></div></TD>
					</CFLOOP>
				</TR>
				<TR height="1%">
					<TD colspan="#qryATTDITEMCODES.RecordCount + 6#" class="leg"> <strong>LEGEND:</strong> </TD>
				</TR>
				<CFQUERY NAME = "qryCLKPYITEMS" datasource="#CLIENT.COMPANY_DSN#">
					SELECT PYITEMCODE, PYITEMDESCRIPTION FROM CLKPYITEMS
					WHERE PYITEMCODE IN ('HRWK'<CFIF qryATTDITEMCODES.RECORDCOUNT>,#QUOTEDVALUELIST(qryATTDITEMCODES.ITEMCODE)#</CFIF>)
				</CFQUERY>
				<TR height="1%">
				<CFLOOP QUERY = "qryCLKPYITEMS">
					<!--- Remove by Teki to make one row for Legend	
					<CFIF CURRENTROW MOD 8>
					<TD colspan="2" class="leg"> <strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION# </TD>
					<CFELSE>
					</TR>
					<TR>
					<TD colspan="2" class="leg"> <strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION# </TD>
					</TR></CFIF>
					--->
					<TD class="leg"> <strong>#PYITEMCODE# :</strong> #PYITEMDESCRIPTION# </TD>
				</CFLOOP>
				<CFELSE>
					TK FILE NOT FOUND.
				</CFIF>
				<TR>
					<TD colspan="#qryATTDITEMCODES.RecordCount + 6#" align="center">
						Downloaded eDTR by #CLIENT.MYNAME# on #dateformat(now(), "mmm dd, yyyy")# #timeformat(now())#.
					</TD>
				</TR>
				</TABLE>
				
			</body>
		</html>
		</CFDOCUMENT>
		</CFOUTPUT>
	</CFIF>
	
	<cfif structkeyexists(url,"eform")>
		<INPUT type="button" value="BACK" onClick="history.back()">
		<cfabort>
	</cfif>
	<CFIF NOT STRUCTKEYEXISTS(FORM,"btnDOWNLOAD") and not structkeyexists(url,"eform")>
	<CFOUTPUT>
	<!---<CFMODULE TEMPLATE = "#client.common_path#cfm_checkuserrecords.cfm" USERTABLE = "ECRTDTR"
			USERFIELD = "USERGRPID_FK" RECORDFIELD = "EDTRCODE_FK" BOOLEANFIELDS="ISVIEWGROUP" RECORDID = "#sEDTRCODE#">--->	
	<CFIF FIELDISVIEWGROUP EQ "Y" OR masterviewgroup eq "Y">
		<table align="left">
		<tr>
		<td>
		
		
		<FORM method="post" action="./groupmain.cfm" name="VIEWGROUP">
			<INPUT type="hidden"  name="sID" VALUE = "#sEDTRCODE#">
			<INPUT type="hidden"  name="GROUPCODE" VALUE = "#getRECORD.GROUPCODE#">
			<INPUT type="hidden"  name="GROUPCODEVAL" VALUE = "#EVALUATE("QRYVIEWER."&GETRECORD.GROUPCODE)#" >
			<INPUT type="submit" value="View Individual eDTR">
		</FORM>
		
		</td>
		<td>
		<CFFORM name="viewall" format="html" method="post" action="index.cfm?#CGI.QUERY_STRING#">
			<cfinput type="submit" value="View all eDTR" name="btnViewAll">
		</CFFORM></td>			
		</tr>
		</table>
	</CFIF>
<table align="left" cellspacing="2" >
          <tr>
<form method="post" action="index.cfm?#CGI.QUERY_STRING#"> 
			<cfif not edtrrouted>
				<cfset normRouting = 1>
				
					<cfif DateFormat(now()) gt DateFormat(cfCutOffEnd)>
						<cfset normRouting = 0>
					</cfif>
				<td>
					<!---
					<INPUT type="submit" value="Save for Routing" name="btnRoute">
					--->
					
					<!---Modified by cholo last 08/26/2011--->
					<!---To resolve the offshoot error reported by Sir Dennis where in the DTR can still be routed even SHAREDUPDATE equals N--->
					<!---start--->
					<CFIF UCASE(GETRECORD.SHAREDUPDATE) EQ "YES">
					<INPUT TYPE = "SUBMIT" VALUE = "Save for Routing" NAME = "BTNROUTE">
					</CFIF>
					<!---end--->
					
					<input type="hidden" value="#normRouting#" name="swForm">
					<input type="hidden" value="#getgroupmates.PERSONNELIDNO#" name="personId">
				</td>
			</cfif>
			<td><INPUT type="button" value="Close" onClick="window.location.assign('#client.domain#edtr/')"></td>
			</form>
          </tr>
        </table>
<table align="right">
  <tr>
    <td><CFIF STDB NEQ "">
	<CFFORM name="EXTRACTVIEW" format="html" method="post" action="index.cfm?#CGI.QUERY_STRING#">
			<CFSELECT name="selEXTRACTTYPE" width="150">
				<!---	<OPTION value="excel"> EXCEL FILE </OPTION>  --->
				<OPTION value="pdfPortrait" selected="true"> PDF FILE PORTRAIT </OPTION>
				<OPTION value="pdfLandscapeLong"> PDF FILE LANDSCAPE </OPTION>
			</CFSELECT>
			<cfinput type="hidden" value="#pid#" name="hiddownloadpid">
			<CFINPUT type="submit" name="btnDOWNLOAD" value="Download eDTR">
	</CFFORM>
	</CFIF>
	</CFOUTPUT>
	</CFIF>
</tr>
</table>
<br/><br/><br/>
</cfloop>
	<cfset session.themessage = "">
		<!---<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" TOP="False"></td>--->	
<!---</CFIF>--->
</BODY>

